<template>
  <van-cell
    class="article-item"
    :to="{
      name: 'article',
      params: {
        articleId: article.art_id,
      },
    }"
  >
    <!-- Vant 中默认包含了一些常用样式 -->
    <div slot="title" class="van-multi-ellipsis--l2">
      {{ article.title }}
    </div>
    <div slot="label">
      <div class="cover-wrap" v-if="article.cover.type === 3">
        <div
          class="cover-wrap-item"
          v-for="(img, index) in article.cover.images"
          :key="index"
        >
          <van-image class="cover-item" fit="cover" :src="img"></van-image>
        </div>
      </div>
      <div class="label-wrap">
        <span>{{ article.aut_name }}</span>
        <span>{{ article.comm_count }}评论</span>
        <span>{{ article.pubdate | relativeTime }}</span>
      </div>
    </div>
    <!-- 默认插槽名字叫 default，可以省略 -->
    <van-image
      slot="default"
      v-if="article.cover.type === 1"
      class="right-cover"
      fit="cover"
      :src="article.cover.images[0]"
    ></van-image>
  </van-cell>
</template>

<script>
export default {
  name: "articleItem",
  props: {
    article: {
      type: Object,
      required: true,
    },
  },
  data() {
    return {};
  },
  computed: {},
  methods: {},
};
</script>
<style lang='less' scoped>
.article-item {
  .title {
    font-size: 32px;
    color: #3a3a3a;
  }
  // 一张封面图
  /deep/ .van-cell__value {
    flex: unset;
    width: 232px;
    height: 146px;
    margin-left: 24px;
  }
  .right-cover {
    width: 232px;
    height: 146px;
    border-radius: 10px;
    overflow: hidden;
  }
  // 三张封面图
  .cover-wrap {
    padding: 20px 0;
    display: flex;
    flex-wrap: nowrap;
    .cover-wrap-item {
      flex: 1;
      height: 146px;
      // 排除最后一个父元素 cover-wrap-item
      &:not(:last-child) {
        padding-right: 10px;
      }
      .cover-item {
        width: 100%;
        height: 100%;
        border-radius: 10px;
        overflow: hidden;
      }
    }
  }

  .label-wrap {
    font-size: 22px;
    color: #b4b4b4;
    span {
      margin-right: 20px;
    }
    span:last-child {
      margin-right: 0;
    }
  }
}
</style>